<?php
/**
 * Commentaire des vendeurs
 *
 * Description de la classe
 *
 * @author Mathieu
 */
class VendorComment extends Comment{
    protected $id;
    protected $vendor_id;
    protected $user_id;
    protected $texte;
    protected $added;

    function __construct($id="", $params=array()) {
        if($id != "") {
            $this->id = $id;
            foreach($params as $key => $p) {
                $this->$key = $p;
            }
            $this->texte = stripslashes($this->texte);
        }
    }

    public function load() {
        $db = Database::getInstance();
        $result = $db->query("SELECT * FROM commentaires_vendors WHERE id = '".$this->id."'");
        if(sizeof($result) > 0) {
            foreach($result[0] as $key => $p) {
                $this->$key = $p;
            }
            $this->texte = stripslashes($this->texte);
            return;
        }
        if(DEBUG) echo("Objet inconnu");
        return false;
    }

    function __toString() {
        if(!isset($this->texte)) $this->load();
        return $this->texte;
    }

    public function delete(){
        $db = Database::getInstance();
        $sql = "DELETE FROM commentaires_vendors WHERE id='".$this->id."'";
        $db->query($sql);
    }
}
?>
